# -*- coding: utf-8 -*-
"""
事件对象 —— 判完 quality 后抛给下游（进程内或 MQ）
"""
from __future__ import annotations

from datetime import datetime
from decimal import Decimal

from pydantic import BaseModel, Field


class QualityEvent(BaseModel):
	"""
	一次硬件上报对应一个事件，三相拆多行但只发一次事件
	"""
	msg_id: str
	meter_code: str
	meter_type: str  # THREE_PHASE / SINGLE_PHASE
	phase: str
	ts: datetime
	quality: str  # GOOD / BAD
	# 以下供告警引擎用，避免再查库
	voltage: Decimal
	current: Decimal
	watt: Decimal
	temperature1: Decimal
	temperature2: Decimal
	raw_snapshot: dict = Field(default_factory=dict)

	class Config:
		json_encoders = {Decimal: str}
